package com.demo.controller;

import com.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class StudentController {

    //1.属性注入
    @Resource
    private StudentService studentService;

    public StudentService getStudentService() {
        return studentService;
    }


//    //2.set注入
//    private StudentService studentService;
//
//    @Autowired
//    public void setStudentService(StudentService studentService) {
//        this.studentService = studentService;
//    }

//    //3.构造方法注入
//    private final StudentService studentService;
//
//    @Autowired
//    public StudentController(StudentService studentService) {
//        this.studentService = studentService;
//    }

//    //4.构造方法注入
//    private final StudentService studentService;
//
//    public StudentController(StudentService studentService) {
//        this.studentService = studentService;
//    }

//    public void play() {
//        studentService.sayHi();
//    }

//    @Autowired
//    @Qualifier("student1")
//    private Student student;
//
//    public void play() {
//        System.out.println(student.toString());
//    }

//    @Resource(name = "student2")
//    private Student student;
//
//    public void play() {
//        System.out.println(student.toString());
//    }

}
